<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start('ob_gzhandler'); else ob_start(); ?>
<?php
/*
 * Copyright 2009 Eat Local Food, LLC
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerceAdmin is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
//paths for GWTCommerce stuff
$include_path = ini_get('include_path');
ini_set('include_path', 'php:' . $include_path);
      
require_once('includes/components/ComponentController.php');
require_once('includes/classes/JSON.php');
require_once('includes/functions/functions.php');
require_once('includes/functions/cache_functions.php');

//Important parameters
//value is an array of parameters sent to components.
$value = $_REQUEST;
$action = prepare_input($_REQUEST['action']);
if ($action == null) $action = 'query';
$value{'action'} = $action;
$languageId = (int)$_REQUEST['languageId'];	
$testSSL = (boolean)$value['testSSL'];  

//handle is the PHP Component to request information from
$handle = 'MultipleResultsComponent';
//value is an array of parameters sent to the component(s).
$value{'handle'} = $handle;

//handles is used in a multi-request, it's all the components having information requested.
$handles = 'AccountsGroupComponent, CatalogGroupComponent, ReportsGroupComponent, ToolsGroupComponent, ConfigurationGroupComponent, ' .
'ModuleGroupComponent, LocationGroupComponent, LocalizationGroupComponent, CurrenciesAdministrationComponent, LanguagesAdministrationComponent, ' .
'CountriesComponent, AccountComponent, ManufacturersAdministrativeComponent, TaxClassesComponent, DiscountCategoriesComponent, ' .
'ProductOptionsComponent, ProductOptionsValuesComponent, ProductOptionsToValuesComponent, OrderStatusComponent, CategoriesProductsComponent,TermsAndConditionsLabelsComponent';

$value{'handles'} = $handles;
$rvalue = actionComponent($value, $action);

$mvalue{'GWTCommerceAdminMetaData'}{'testSSL'}= $testSSL;
$mvalue{'GWTCommerceAdminMetaData'}{'store_name_address'}= nl2br(STORE_NAME_ADDRESS);
$rvalue = array_merge($mvalue, $rvalue);


$json = new Services_JSON();
$jsonStr = $json->encode($rvalue);
//$jsonStr = json_encode($rvalue);

?>
<!DOCTYPE HTML PUBLIC >
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="gwt:property" content="locale=<?php echo DEFAULT_LANGUAGE ?>">
    <title><?php echo STORE_NAME ?>  Administration</title>
    <link rel="stylesheet" href="gwtCommerceAdmin/GWTCommerceAdmin.css"/>
    <link rel="stylesheet" href="gwtCommerceAdmin/GWTCommerceAdminWait.css"/>
    <link rel="stylesheet" href="gwtCommerceAdmin/GWTCommerceAdminPrint.css" media="print" />
  </head>
  <body>
    <!-- OPTIONAL: include this if you want history support -->
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>

<form id="loginForm" class="LoginPanel" action="<?php echo $loginFormAction?>" style="display: none;" method="post">
  <table class="AccountComponentSubPanel" style="width: 100%;">
    <tbody>
      <tr>
        <td style="white-space: nowrap;">E-Mail Address:</td>
        <td><input class="gwt-TextBox" type="text" tabindex="0" name="email_address"/></td>
        <td class="WarningLabel AccountComponentWarningLabel" width="100%" style="white-space: nowrap;"></td>
      </tr>
      <tr>
        <td style="white-space: nowrap;">Password:</td>
        <td><input class="gwt-PasswordTextBox" type="password" tabindex="0" name="password"/></td>
        <td class="WarningLabel AccountComponentWarningLabel" width="100%" style="white-space: nowrap;"></td>
      </tr>
      <tr>
        <td> </td>
      </tr>
      <tr>
        <td><input type="submit" value="sign in" /></td>
      </tr>
    </tbody>
  </table>
  <input type="hidden" name="action" value="LoginAccount"/>
  <input type="hidden" name="cart" value=""/>
  <input type="hidden" name="token" value=""/>
</form>

    <script>var initial_json = "<?php echo $jsonStr ?>";</script>
    <script type="text/javascript" language="javascript" src="gwtCommerceAdmin/gwtCommerceAdmin.nocache.js"></script>
  </body>
</html>
<?php
?>
